package cn.yshujia.controller;

import cn.yshujia.domain.vo.ApiVO;
import cn.yshujia.service.impl.AuthorizeServiceImpl;
import cn.yshujia.service.impl.RoleServiceImpl;
import cn.yshujia.service.impl.UserServiceImpl;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.annotation.Resource;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.Map;

/**
 * @author YShuJia
 * @create 2025/1/3
 * @description AuthorizeController
 */

@RestController
@Tag (name = "Authorize", description = "授权模块Api")
public class AuthorizeController {
	
	@Resource
	private AuthorizeServiceImpl service;
	
	@Resource
	private UserServiceImpl userService;
	
	@Resource
	private RoleServiceImpl roleService;
	
	@GetMapping ("/exchange/sm2")
	public ApiVO<String> exchangeSM2Key() {
		return ApiVO.success(service.exchangeSM2Key());
	}
	
	@GetMapping ("/admin/authorize/count")
	public ApiVO<Map<String, Number>> count() {
		return ApiVO.success(Map.of(
				"user", userService.count(),
				"role", roleService.count()
		));
	}
}
